﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Main.Master" AutoEventWireup="true" CodeBehind="SelectProviders.aspx.cs" Inherits="Linkmeme.Views.User.SelectProviders" %>
<%@ Import Namespace="Linkmeme" %>
<%@ Import Namespace="Linkmeme.Controllers" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">


    <div id="lfeature">
          <div class="btitle">
            <h4>选择...</h4>
          </div>
        
        
       <%-- <asp:ListView runat="server" ID="availableProviderList" GroupPlaceholderID="groupPlaceHolder" >
        <LayoutTemplate>
            <ul>
                <asp:PlaceHolder runat="server" ID="groupPlaceHolder"></asp:PlaceHolder>
            </ul>
        </LayoutTemplate>
        <GroupTemplate>
            
            <asp:PlaceHolder runat="server" ID="itemPlaceHolder"></asp:PlaceHolder>
            
        </GroupTemplate>
        <ItemTemplate>
            <span><%# Eval("GroupKey")%></span>
            <asp:BulletedList ID="blist" runat="server" DataSource='<%# Eval("Items")%>' DataValueField="Name" />
        </ItemTemplate>
        </asp:ListView>--%>
        
        <ul id='providerList'>
        <%foreach (var item in this.ViewData.GroupedProviders)
          {
              %>
                <li>
                    <span><%= item.GroupKey.ToCH()%></span>
                    <ul>
                        <%foreach (ContentProvider provider in item.Items)
                          {
                              %>
                              <li style="display:inline">
                              <span>
                              <span><%= provider.Name%></span>
                              <%//= Html.ActionLink<UserController>(c => c.AddSource(provider.ID)," [+]", new { tooltip="add for me"})%>
                              <a href='<%= provider.ID%>' title="Add this for me"> [+]</a>
                              </span>
                              </li>
                              <%
                          } %>
                    </ul>
                </li>      
              <%
          } %>
        </ul>
        
        
    </div>
    
    <div id="rfeature">
        <div class="btitle">
            <h4>
                我的...</h4>
        </div>
        <%foreach (UserSelectedProvider item in this.ViewData.UserProviders)
          {
              
              %>
              <%= item.ProviderName%> &nbsp;(<%= item.ProviderUserName%>) <%= Html.ActionLink<UserController>(c=>c.RemoveProvider(item.ID), " [-]") %><br />
              <%
          } %>
        <%--<asp:Repeater runat="server" ID="userProviderList">
            <ItemTemplate>
                <a href="#">
                    <%# Eval("ProviderName")%>&nbsp;<%# Eval("ProviderUserName")%><br />
            </ItemTemplate>
        </asp:Repeater>--%>
    </div>
    
    <div id="maincontent">
        <%--<a href="#" class="jqModal">view</a> --%>
        <div class="mainblock" style="display:none" id="dialog">
            <div class="btitle">
              <h4></h4>
            </div>
           <input id="username" value="" /> &nbsp;
           <a id="checkUser" href="CheckUser/">Check</a> &nbsp;
           <span id="checkresult" style="color:Red"></span>
           <input type="hidden" id="providerid" value='' />
        </div>
    </div>

<script language="javascript">
    $(document).ready(function() {
        $('#providerList a').click(function()
            {
                var id = $(this).attr('href');
                var provname = $(this).prev().text();
                
                $('#dialog h4').text("请输入你在"+provname+"的用户名");
                $('#dialog #username').attr('value', '');
                $("#dialog #providerid").attr("value", id);
                
                $("#dialog").show("fast");
                
                return false;   
            });
        
        $("#dialog #checkUser").click(function()
            {
                var providerid = $('#dialog #providerid').attr('value');
                var username = $('#dialog #username').attr('value');
                
                $.getJSON($("#dialog #checkUser").attr("href")+providerid+"\/"+username, 
                    function(result)
                    {
                        if (result.isSuccessful == false)
                            $('#dialog #checkresult').text(result.errorMessage);
                        else 
                            window.location.reload();
                    }
                );
                
                return false;
            });
    });
</script>
</asp:Content>

